<?php 
	require_once('conn/DBconnect.php'); 

	session_start();

	$firstName = "";
 	$lastName = "";
 	$middleIni = "";
 	$gender = "";
 	$bdate = "";
 	$email = "";
 	$mobile = "";
 	$nationality = "";
 	$country_code = "";
 	$address1 = "";
 	$address2 = "";
 	$deliveryAdd = "";
 	$contactName = "";
 	$contactPhone = "";
 	
	if(isset($_SESSION['loggedUser']))
	{
		$firstName = $_SESSION["loggedUser"]["pi_first_name"];
	 	$lastName = $_SESSION["loggedUser"]["pi_last_name"];
	 	$middleIni = $_SESSION["loggedUser"]["pi_middle_initial"];
	 	$gender = $_SESSION["loggedUser"]["pi_gender"];
	 	$bdate = $_SESSION["loggedUser"]["pi_birthdate"];
	 	$email = $_SESSION["loggedUser"]["pi_email_add"];
	 	$mobile = $_SESSION["loggedUser"]["pi_mobile_no"];
	 	$nationality = $_SESSION["loggedUser"]["pi_nationality"];
	 	$country_code = $_SESSION["loggedUser"]["pi_country"];
	 	$address1 = $_SESSION["loggedUser"]["pi_address1"];
	 	$address2 = $_SESSION["loggedUser"]["pi_address2"];
	 	$deliveryAdd = $_SESSION["loggedUser"]["pi_delivery_add"];
	 	$contactName = $_SESSION["loggedUser"]["pi_contact_name"];
	 	$contactPhone = $_SESSION["loggedUser"]["pi_contact_phone"];
	}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Color Manila Run - Change Password</title>
<link rel="stylesheet" href="styles/layout.css" type="text/css" media="screen"/>
<script src="scripts/home.js"></script>
<script src="scripts/profile.js"></script>
<script src="scripts/jquery-1.8.2.js"></script>
<script src="scripts/jquery.md5.js"></script>
<script src="scripts/jquery.sha1.js"></script>
<script src="scripts/textinputUtils.js"></script>
<script src="scripts/preloadercontrol.js"></script>

</head>
<body marginheight="0" marginwidth="0">
<div id="preloader"><div><img src="images/ajax-loader.gif" width="50" height="50"/></div></div>
<div id="regMainContainer">
	<div class="divContainer">
		<div id="div-header">
			<div class="div-header-title">
				<div class="dh-title-left"></div>
				<div class="dh-title-center">Change Password</div>
				<div class="dh-title-right"></div>
			</div>
		</div>
		<div class="divContent">
			<div class="formItem">
				<div class="formLabelRight" style="width:150px;"><font color="#ff0000">*</font>Old Password</div>
				<div>
				<input type="password" name="oldPassword" class="formInput" maxlength="50" value=""/>
				</div>
				<div id="oldPassErrorMsg" class="formErrorMsg"></div>
			</div>
			<div class="formItem">
				<div class="formLabelRight" style="width:150px;"><font color="#ff0000">*</font>New Password</div>
				<div>
				<input type="password" name="newPassword" class="formInput" maxlength="50" value=""/>
				</div>
				<div id="newPassErrorMsg" class="formErrorMsg"></div>
			</div>
			<div class="formItem">
				<div class="formLabelRight" style="width:150px;"><font color="#ff0000">*</font>Confirm Password</div>
				<div>
				<input type="password" name="confirmPassword" class="formInput" maxlength="50" value=""/>
				</div>
				<div id="confirmPassErrorMsg" class="formErrorMsg"></div>
			</div>
			<div class="divSpacer"></div>
			<div class="formItem">
				<div id="resetResult" class="formLabelRight" style="width:300px;">&nbsp;</div>
			</div>
			<div id="buttonMenuList" class="formButtonMenuList">
				<div id="changePassButton" class="formButtonMenu">
					<div class="blue-buttonBL"></div>
					<div id="btnChangePass" class="blue-buttonM" style="width:140px;">
					<a href="javascript:changePasswordSubmit()">Change Password</a>
					</div>
					<div class="blue-buttonBR"></div>
				</div>
			</div>
		</div>
		<div>
			<div style="width:580px;padding:2px 10px;">
				<hr class="hrDashedThin">
			</div>
		</div>
		<div id="div-header">
			<div class="div-header-title">
				<div class="dh-title-left"></div>
				<div class="dh-title-center">Profile</div>
				<div class="dh-title-right"></div>
			</div>
		</div>
		<div class="divContent">
			<div class="formItem">
				<div class="formLabelRight"><font color="#ff0000">*</font>Email address</div>
				<div>
				<input type="text" name="emailAdd" class="formInputEmail" maxlength="50" value="<?php echo $email?>" disabled='disabled'/>
				</div>
				<div id="emailErrorMsg" class="formErrorMsg"></div>
			</div>
			<div class="formItem">
				<div class="formLabelRight"><font color="#ff0000">*</font>First name</div>
				<div><input type="text" name="firstName" class="formInputAlphabet" maxlength="50" value="<?php echo $firstName?>"/></div>
				<div id="firstNameErrorMsg" class="formErrorMsg"></div>
			</div>
			<div class="formItem">
				<div class="formLabelRight"><font color="#ff0000">*</font>Last name</div>
				<div><input type="text" name="lastName" class="formInputAlphabet" maxlength="50" value="<?php echo $lastName?>"/></div>
				<div id="lastNameErrorMsg" class="formErrorMsg"></div>
			</div>
			<div class="formItem">
				<div class="formLabelRight">Middle Initial</div>
				<div><input type="text" name="middleInitial" class="formInputAlphabet" maxlength="1" value="<?php echo $middleIni?>"/></div>
			</div>
			<div class="formItem">
				<div class="formLabelRight"><font color="#ff0000">*</font>Gender</div>
				<div>
					<div><input type="radio" name="gender" value="M" <?php if($gender == "M"){ echo "checked='checked'";} ?>></div>
					<div class="formLabel" style="width:60px;">Male</div>
					<div><input type="radio" name="gender" value="F" <?php if($gender == "F"){ echo "checked='checked'";} ?>></div>
					<div class="formLabel" style="width:60px;">Female</div>
				</div>
				<div id="genderErrorMsg" class="formErrorMsg"></div>
			</div>
			<div class="formItem">
				<div class="formLabelRight"><font color="#ff0000">*</font>Date of birth</div>
				<div><input type="text" name="birthDate" class="formInputDate" maxlength="10" value="<?php echo $bdate?>"/></div>
				<div id="birthDateErrorMsg" class="formErrorMsg"></div>
			</div>
			<div class="formItem">
				<div class="formLabelRight" style="width:200px;">&nbsp;</div>
				<div><i>format: mm/dd/yyyy</i></div>
			</div>
			<div class="formItem">
				<div class="formLabelRight">Mobile</div>
				<div><input type="text" name="mobileNo" class="formInputNumbers" maxlength="11" value="<?php echo $mobile?>"/></div>
			</div>
			<div class="formItem">
				<div class="formTitleLabel" style="text-align:right;">Your address</div>
			</div>
			<div class="formItem">
				<div class="formLabelRight"><font color="#ff0000">*</font>Home Address</div>
				<div><input type="text"  name="address1" class="formInput" maxlength="200" value="<?php echo $address1?>"/></div>
				<div id="homeAddErrorMsg" class="formErrorMsg"></div>
			</div>
			<div class="formItem">
				<div class="formLabelRight">Delivery Address</div>
				<div>
					<div><input type="radio" name="deliveryAdd" value="HOME" <?php if($deliveryAdd == "" || $deliveryAdd == "HOME"){ echo "checked='checked'";} ?>></div>
					<div class="formLabel" style="width:60px;">HOME</div>
					<div><input type="radio" name="deliveryAdd" value="ADD2" <?php if($deliveryAdd == "ADD2"){ echo "checked='checked'";} ?>></div>
					<div class="formLabel" style="width:80px;">ADDRESS 2</div>
				</div>
			</div>
			<div class="formItem">
				<div class="formLabelRight">Address 2</div>
				<div><input type="text" name="address2" class="formInput" maxlength="200" value="<?php echo $address2?>"/></div>
				<div id="add2ErrorMsg" class="formErrorMsg"></div>
			</div>
			<div class="formItem">
				<div class="formLabelRight"><font color="#ff0000">*</font>Country</div>
				<div>
					<select name="country" class="formInput">
					<?php 
			
						$countrySQL = "call sp_countries('LIST',null,null);";
	
						$result = mysqli_query($mysqlLink, $countrySQL);
						
						$isChecked = false;
						while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) 
						{
							if($country_code == "" && $row["ccode"] == "PH"){
								$isChecked = true;
							}
							else if($country_code == $row["ccode"]){
								$isChecked = true;
							}
					?>
					
						<option value="<?php echo $row["ccode"]; ?>" <?php if($isChecked){ echo "selected='selected'"; $isChecked=false; } ?> ><?php echo $row["country"]?></option>
					
					<?php
						}
	
						/* free result set */
						mysqli_free_result($result);
						
						/* close connection */
						mysqli_close($mysqlLink);
					?>
					</select>
				</div>
			</div>
			<div class="formItem">
				<div class="formLabelRight"><font color="#ff0000">*</font>Nationality</div>
				<div><input type="text" name="nationality" class="formInputAlphabet" maxlength="50" value="<?php echo $nationality?>"/></div>
				<div id="nationalityErrorMsg" class="formErrorMsg"></div>
			</div>
			
			<div class="formItem">
				<div class="formLabelRight">Emergency contact name</div>
				<div><input type="text" name="cantactName" class="formInputAlphabet" maxlength="100" value="<?php echo $contactName?>"/></div>
			</div>
			<div class="formItem">
				<div class="formLabelRight">Emergency contact phone</div>
				<div><input type="text" name="contactPhone" class="formInputNumbers" maxlength="15" value="<?php echo $contactPhone?>"/></div>
			</div>
		</div>
		<div class="divSpacer"></div>
		<div id="buttonMenuList" class="formButtonMenuList">
			<div id="updateButton" class="formButtonMenu">
				<div class="blue-buttonBL"></div>
				<div id="btnUpdate" class="blue-buttonM">
				<a href="#">Update</a>
				</div>
				<div class="blue-buttonBR"></div>
			</div>
		</div>
	</div>
	<input type="hidden" name="tokenNumber" value="<?php echo $_SESSION['tokenNumber']?>">
</div>
</body>
<script>

$("#preloader").css({ opacity: 0.5 });

showPreloader(false);

$("#regMainContainer").click(function()
{
	$(".formInputEmail").blur(function(e){
		validateEmailAddress(e, $("#emailErrorMsg"));
	}); 
});

</script>
</html>